<template>
    <tig-form :action="action" :isUpdate="isUpdate">
        <default-field>

            <template slot="label" :fieldName="'title'">标题</template>

            <template slot="field">
                <input title="标题" name="title" class="w-full form-control form-input form-input-bordered"
                       :value="title"/>
            </template>
        </default-field>
        <default-field fieldName="introduction">

            <template slot="label">作品介绍（可选）</template>

            <template slot="field">
                <textarea title="作品介绍" name="introduction"
                          class="w-full form-control form-input form-input-bordered py-3 min-h-textarea"
                >{{introduction}}</textarea>
            </template>
        </default-field>
        <default-field field-name="url">

            <template slot="label">原文链接（可选）</template>

            <template slot="field">
                <input title="原文链接" name="url" class="w-full form-control form-input form-input-bordered"
                       :value="url"/>
            </template>
        </default-field>
        <default-field>

            <template slot="label" :fieldName="'type'">类型</template>

            <template slot="field">
                <select title="类型" name="type" class="w-full form-control form-select">
                    <option value="0" :selected="type===0?'selected':''">普通模式</option>
                    <option value="1" :selected="type===1?'selected':''">接龙模式</option>
                    <option value="2" :selected="type===2?'selected':''">个人模式</option>
                </select>
                <help-text>
                    普通模式：他人可以创建副本（fork），并在副本上进行续写或修改，他人续写或修改完毕后，可以向原作者提交更新请求（pull request），覆盖（merge）原先的版本。 <br>
                    接龙模式：任何人可以在当前作品中自由修改或续写 <br> 个人模式：作者不允许任何人创建副本，续写和修改
                </help-text>
            </template>
        </default-field>
        <default-field>

            <template slot="label" field-name="tag">标签（可选）</template>

            <template slot="field">
                <tig-tag-field :tags="tags"></tig-tag-field>
            </template>
        </default-field>
        <default-field>

            <template slot="field">
                <input type="submit" class="btn btn-default btn-primary cursor-pointer" :value="submitButtonText">
            </template>


        </default-field>

    </tig-form>
</template>

<script>
    export default {
        name: "RepositoryForm", props: {
            action: {type: String, required: true},
            title: String,
            introduction: String,
            url: String,
            tags: Array,
            type: {
                type: Number,
                default: 0
            },
            submitButtonText: {
                type: String,
                default: '创建'
            },
            isUpdate: {
                type: Boolean,
                default: false
            }
        }
    }
</script>

<style scoped>

</style>